<template>
    <div>
        <div class="header">
            <span class="search-header">搜索用户数</span>
            <i class="el-icon-warning-outline"></i>
        </div>
        <div class="main">
            <span class="main-title">123321</span>
            <span class="main-container">17.1</span>
            <i class="el-icon-top" style="color:red"></i>
            <i class="el-icon-bottom" style="color:green"></i>
        </div>
        <div class="footer">
            <!-- 折线图 -->
            <div class="charts" ref="charts"></div>
        </div>
    </div>
</template>

<script>
// 引入echarts
import * as echarts from 'echarts'

export default {
    name: 'LineCharts',
    // 使用echarts
    mounted() {
        let lineChart = echarts.init(this.$refs.charts)

        lineChart.setOption({
            // x轴的配置项
            xAxis: {
                type: 'category',
                show: false
            },
            // y轴的配置项
            yAxis: {
                show: false
            },
            // 系列
            series: [
                {
                    type: 'line',
                    data: [10, 7, 33, 12, 20, 9, 29, 10, 44],
                    // 拐点样式设置
                    itemStyle: {
                        opacity: 0
                    },
                    // 线条的样式
                    lineStyle: {
                        color: 'purple'
                    },
                    // 填充颜色设置(渐变)
                    areaStyle: {
                        color: {
                            type: 'linear',
                            x: 0,
                            y: 0,
                            x2: 0,
                            y2: 1,
                            colorStops: [{
                                offset: 0, color: 'purple' // 0% 处的颜色
                            }, {
                                offset: 1, color: '#fff' // 100% 处的颜色
                            }],
                            global: false // 缺省为 false
                        }
                    },
                    // 设置圆润
                    smooth: true,

                }
            ],
            // 布局调试
            grid: {
                left: 0,
                top: 0,
                bottom: 0,
                right: 0
            }
        })
    }
}
</script>

<style scoped>
.charts {
    width: 100%;
    height: 100px;
}

.header {
    display: flex;
    align-items: center;
}

.search-header {
    margin-right: 10px
}

.main {
    margin: 10px 0;
}
</style>